package com.yundasys.lab12java.thread;

/**
 * @PACKAGE_NAME: com.yundasys.lab12java.thread
 * @NAME: ThreadLocalDemo
 * @USER: jiangta
 * @DATE: 2021/10/27
 * @TIME: 10:41 上午
 * @PROJECT_NAME: springboot-labs
 */
public class ThreadLocalDemo {

    /**
     * The difference between successively generated hash codes - turns
     * implicit sequential thread-local IDs into near-optimally spread
     * multiplicative hash values for power-of-two-sized tables.
     */
    private static final int HASH_INCREMENT = 0x61c88647;

    public static void main(String[] args) {
        int hashCode =0;
        for(int i=0;i<16;i++) {
            hashCode = i*HASH_INCREMENT + HASH_INCREMENT;
            int bucket = hashCode & (16-1);
            System.out.println(i+" 在桶中的位置：" + bucket);
        }

    }
}
